package cn.edu.neusoft.yuejian4.yuejian_4.adapter;

import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.yuejian4.yuejian_4.Config.Server;
import cn.edu.neusoft.yuejian4.yuejian_4.R;
import cn.edu.neusoft.yuejian4.yuejian_4.javaBean.ClubVideo;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

/**
 * Created by Lix on 2018/10/login_bg2.
 */

public class ClubVideoAdapter extends RecyclerView.Adapter<ClubVideoAdapter.ViewHolder>  {

    private List<ClubVideo> mClubVideo;
    private Context mContext;

    public ClubVideoAdapter(Context mContext, List<ClubVideo> mClubVideo){
        this.mContext = mContext;
        this.mClubVideo = mClubVideo;
        //mLayoutInflater = LayoutInflater.from(mContext);
    }


    @Override
    public ClubVideoAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.club_video_cardview,parent,false);
        ClubVideoAdapter.ViewHolder holder = new ClubVideoAdapter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(final ClubVideoAdapter.ViewHolder holder, int position) {
        final ClubVideo clubVideo = mClubVideo.get(position);
        holder.clubvideoIntro.setText(clubVideo.getIntro());
        holder.clubvideo.setUp(Server.PIC_URL_J+clubVideo.getName(), JCVideoPlayer.SCREEN_LAYOUT_LIST, "");
        String path = "http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640";
        Uri uri = Uri.parse(path);
        holder.clubvideo.thumbImageView.setImageURI(uri);

    }

    @Override
    public int getItemCount() {
        return mClubVideo.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        TextView clubvideoIntro;
        JCVideoPlayerStandard clubvideo;
       // FrameLayout clubvideo_container;

        public ViewHolder(View view){
            super(view);
            clubvideo= (JCVideoPlayerStandard)view.findViewById(R.id.club_video_name);
            clubvideoIntro = (TextView)view.findViewById(R.id.clubintro_name);
           // clubvideo_container = (FrameLayout)view.findViewById(R.id.clubvideo_container);
        }
    }
}
